#include "FreeRTOS.h"
#include "task.h"
#include "stdio.h"

#include "led.h"
#include "beep.h"
#include "usart.h"
#include "adc.h"
#include "oled.h"
#include "oledfont.h"
char buf[128] = {0};
int num = 0;



//void vTaskLED(void * pvParameters)
//{
//	for(;;)
//	{
//		ledOpen(GPIO_Pin_8);
//		vTaskDelay(1000);
//		ledClose(GPIO_Pin_8);
//		vTaskDelay(1000);
////		vTaskDelete(LEDHanle);
//	}
//}
//
//void vTaskBeep(void * pvParameters)
//{
//	for(;;)
//	{
//		beepOpen();
//		vTaskDelay(500);
//		beepClose();
//		vTaskDelay(500);
//	}
//}
//void vTaskADC(void *pvParameters)
//{
//	for(;;)
//	{
//		printf("adc_data = %d\r\n",adcAverageValue());
//		vTaskDelay(2000);
//	}
//}
void oledShowWindow1()
{
	OLED_ShowPicture(5,5,100,50,gImage_111,1);	
}

void oledShowWindow2()
{
	OLED_ShowChinese(12,2,0,16,1);//华
	OLED_ShowChinese(30,2,1,16,1);//清
	OLED_ShowChinese(48,2,2,16,1);//远
	OLED_ShowChinese(66,2,3,16,1);//见
	OLED_ShowChinese(84,2,4,16,1);//教
	OLED_ShowChinese(102,2,5,16,1);//育
	//LED1:X(开/关)
	OLED_ShowString(8,20,"LED1:",12,1);
	
	//LED2:X(开/关)
	OLED_ShowString(70,20,"LED2:",12,1);
	
	//LED3:X(开/关)
	OLED_ShowString(8,35,"LED3:",12,1);

	//蜂鸣器:X(开/关)
	OLED_ShowChinese(70,35,2,12,1);
	OLED_ShowChinese(82,35,3,12,1);
	OLED_ShowChinese(94,35,4,12,1);
	OLED_ShowString(106,35,":",12,1);
	
	//光照强度:xxx(三位数数字)
	OLED_ShowChinese(8,50,5,12,1);
	OLED_ShowChinese(20,50,6,12,1);
	OLED_ShowChinese(32,50,7,12,1);
	OLED_ShowChinese(44,50,8,12,1);
	OLED_ShowString(56,50,":",12,1);

	while(1)
	{
		//LED1
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_8) == 1)
		{
			OLED_ShowChinese(40,20,1,12,1);
		}
		else
		{
			OLED_ShowChinese(40,20,0,12,1);
		}
		//LED2
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_9) == 1)
		{
			OLED_ShowChinese(102,20,1,12,1);
		}
		else
		{
			OLED_ShowChinese(102,20,0,12,1);
		}
		//LED3
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_10) == 1)
		{
			OLED_ShowChinese(40,35,1,12,1);
		}
		else
		{
			OLED_ShowChinese(40,35,0,12,1);
		}
		//蜂鸣器
		if(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_10) == 1)
		{
			OLED_ShowChinese(113,35,0,12,1);
		}
		else
		{
			OLED_ShowChinese(113,35,1,12,1);
		}

		OLED_Refresh();
	}
	
}

int main(){
	ledInit(GPIO_Pin_8);//初始化led1
	beepInit();//初始化蜂鸣器
	OLED_Init();//初始化OLED
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	oledShowWindow1();


	
}









//xTaskCreate(vTaskLED,"vTaskLED",128,NULL,1,&LEDHanle);
//xTaskCreate(vTaskBeep,"vTaskBeep",128,NULL,2,&BeepHanle);
//xTaskCreate(vTaskADC,"vTaskADC",256,NULL,2,&ADCHanle);
//
//vTaskStartScheduler();

